package elubrication;

import java.util.HashMap;

import ihm.AbstractModule;
import ihm.BarreMenu;

import javax.swing.ImageIcon;
import javax.swing.JFrame;

import lecteurmusique.LecteurMusique;

import navigateur.Navigateur;

public class MumWindow extends JFrame {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private HashMap<String, AbstractModule> _myModules = new HashMap<String, AbstractModule>();
	
	private BarreMenu barre_menu;
	
//	private BarreOutil barre_outil;
//	private JPanel barre_laterale;
//	private JTabbedPane cadre_principal;
	
	public static void main(String[] args) {
		
		// Launch this program with a new thread
		javax.swing.SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				MumWindow.createAndShowGUI();
			}
		});
	}

	public static void createAndShowGUI() {
		new MumWindow();
	}
	
	public MumWindow() {
		
		build();
		
		setTitle("Navigateur - Explorateur - Mélomane - RSS - Sans nom");
		setSize(800, 600);
		setLocationRelativeTo(null);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setIconImage(new ImageIcon("connect.png").getImage());
		setVisible(true);
	}
	
	private void build() {
		
		barre_menu = new BarreMenu();
		this.setJMenuBar(barre_menu);
		
		changeModule("BROWSER");
	}
	
	public void changeModule(String moduleName) {
		AbstractModule module = null;
		
		System.out.println("GO " + moduleName + " !!");
		
		if(_myModules.containsKey(moduleName)) {
			module = _myModules.get(moduleName);
			
		} else {
		
			if (moduleName.equals("BROWSER"))
				module = new Navigateur(this);
			else if (moduleName.equals("MUSIC"))
				module = new LecteurMusique(this);
			else if (moduleName.equals("FOLDER"))
				module = null;
			else if (moduleName.equals("RSS"))
				module = null;
			
			_myModules.put(moduleName, module);
		}
		
		if(module != null)
			setContentPane(module);
	}
}
